package com.qingneng.probiz.web;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ModelDriven;
import com.qingneng.probiz.service.sdk.IClientInfoService;
import com.qingneng.probiz.vo.ProClientInfo;
import com.tbfs.common.BaseAction;

/**
 * 客户信息管理相关Action
 *
 */
@SuppressWarnings("serial")
public  class ClientInfoAction extends BaseAction implements ModelDriven<ProClientInfo>{
	
	// 日志相关
	private static final Logger logger = Logger
	.getLogger(ClientInfoAction.class);
	
	// init service
	public IClientInfoService clientInfoService;

	// 构造函数
	public ClientInfoAction(IClientInfoService clientInfoService) {
		this.clientInfoService = clientInfoService;
	}
    
	public ClientInfoAction() {

	}

	private ProClientInfo clientInfo=new ProClientInfo();
	
	public ProClientInfo getClientInfo() {
		return clientInfo;
	}

	public void setClientInfo(ProClientInfo clientInfo) {
		this.clientInfo = clientInfo;
	}

	/**
	 * 保存客户信息
	 * @return
	 */
	public String save() {
		logger.info(" save() ClientInfoAction start ");
		try {
			int id = clientInfo.getClientId()==null?0:clientInfo.getClientId();
			if(id>0){
				clientInfoService.modify(clientInfo);
			}else{
				clientInfoService.add(clientInfo);
			}
		} catch (Exception e) {
			logger.info(" save() ClientInfoAction error:  "+e.getMessage());
			e.printStackTrace();
		}
		logger.info(" save() ClientInfoAction end  ");
		return Action.SUCCESS;
	}
	
	/**
	 * 删除客户信息
	 * @return
	 */
	public String destoryData() {
		logger.info(" destoryData() ClientInfoAction start ");
		logger.info(" destoryData() ClientInfoAction param: "+clientInfo.getClientId());
		try {
			clientInfoService.destory(clientInfo);
			
		} catch (Exception e) {
			logger.info(" destoryData() ClientInfoAction error:  "+e.getMessage());
			e.printStackTrace();
		}
		logger.info(" destoryData() ClientInfoAction end ");
		return Action.SUCCESS;
	}
	
	public ProClientInfo getModel() {
		return clientInfo;
	}


}
